<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>回收商品每日更新表列表</title>
</head>
<body>
<form>
       输入关键字：<input id="keyword" name="keyword"/>
    <input type="button" value="查询" id="cxBtn"/>
</form>
<table width="100%" border="1">
    <caption>回收商品每日更新表列表</caption>
    <thead>
    <tr style="font-weight:bold;background:#a0a0ff">
            <td>更新ID</td>
            <td>商品ID</td>
            <td>更新前回收价格</td>
            <td>更新后回收价格</td>
            <td>创建时间</td>
            <td>其他</td>
            <td>其他</td>
        <td>操作</td>
    </tr>
    </thead>
    <tbody>
    </tbody>
</table>
<script src="/js/jquery-1.12.4.js"></script>
    <script>
    $(function(){
        fill("/productupdateday/findAll.json","");
        $("#cxBtn").click(function(){
            fill("/productupdateday/query.json",$("form").serialize());
        });
    });
    //填充数据
    function fill(url,data){
        $.getJSON(url,data,function(list){
            $("tbody").empty();
            for(var i in list){
                var detail = list[i];
                var str="<tr>";
                str+="<td>"+detail.updateId+"</td><td>"+detail.productId+"</td><td>"+detail.beforeUpdatePrice+"</td><td>"+detail.afterUpdatePrice+"</td><td>"+detail.createTime+"</td><td>"+detail.other1+"</td><td>"+detail.other2+"</td>";
                str+="<td><a href='javascript:view("+detail.updateId+")'>查看</a>&nbsp;&nbsp;";
                str+="<a href='javascript:update("+detail.updateId+")'>修改</a>&nbsp;&nbsp;";
                str+="<a href='javascript:del("+detail.updateId+")'>删除</a>";
                str+="</td></tr>";
                $("tbody").append(str);
            }
        });
    }
    //查看明细
    function view(updateId){
        location.href="/admin/productupdateday/detail.html?updateId="+updateId;
    }
    //更新
    function update(updateId){
        location.href="/admin/productupdateday/update.html?updateId="+updateId;
    }
    //删除
    function del(id){
        $.post("/productupdateday/delete.json",
               {updateId:updateId},
               function(result){
                   if(result.flag==true){
                        fill("/productupdateday/query.json",$("form").serialize());
                        alert("删除成功");
                   }else{
                        alert("删除失败");
                   }
               },"json");
    }
</script>
</body>
</html>